﻿using System;
using System.Collections.Generic;
using System.Text;
using MyCadDll;
using System.IO;

namespace CadStrategy2013.CgqStyle
{
    public class JyDyClass:Cgq2013
    {
        public JyDyClass(string secname)
            : base(secname)
        {
            mycad = new MyCad("./\\" + StationName + "\\" + TemplateFileName);
        }
        public MyCad mycad;
        //public override void GetCfg()
        //{
        //    base.GetCfg();
        //   // GetCfg("绝缘");
        //    mycad = new MyCad("./\\" + StationName + "\\" + TemplateFileName);
        //}
        public override void WriteDwg()
        {
            mycad.StartCad();
            mycad.WriteIniToJyCad();
            mycad.WriteIniToDyCad();
        }
        private void CopyJyFile(string istyle,string destPath,string sourcePath)
        {
            string strn = Inicfg.GetString("绝缘", istyle, "");
            string[] strns = strn.Split(new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string str in strns)
            {
                try
                {
                    File.Copy(sourcePath + "\\jy\\" + str + ".dwg", destPath + "\\" + str + ".dwg", false);
                }
                catch
                {

                }
            }
        }
        public void GetJyFile(string istyle,string destPath,bool isFuJia=false)
        {
            string sourcePath = System.Environment.CurrentDirectory;
            CopyJyFile(istyle + "n", destPath, sourcePath);
            CopyJyFile(istyle + "y", destPath, sourcePath);
            if(isFuJia==false)
            CopyJyFile(istyle + "yl", destPath, sourcePath);
            
            
            //string strn=Inicfg.GetString("绝缘", istyle + "n", "");
            //string[] strns = strn.Split(new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries);
            //string stry = Inicfg.GetString("绝缘", istyle + "y", "");
            //string[] strys = stry.Split(new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries);
            //string stryl = Inicfg.GetString("绝缘", istyle + "yl", "");
            //string[] stryls = stry.Split(new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries);
            //string sourcePath = System.Environment.CurrentDirectory;
            //foreach (string str in strns)
            //{
            //    try
            //    {
            //        File.Copy(sourcePath + "\\jy\\" + str + ".dwg", destPath + "\\" + str + ".dwg", false);
            //    }
            //    catch(IOException e)
            //    {
                     
            //    }
            //}
            //foreach (string str in strys)
            //{
            //    try
            //    {
            //        File.Copy(sourcePath + "\\jy\\" + str + ".dwg", destPath + "\\" + str + ".dwg");
            //    }
            //    catch (IOException e)
            //    {

            //    }
            //}
        }
    }
}
